home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
text
/
misc
/
ht.lha
/
hypertext
/
Rexx
/
link.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1990-12-23
|
8KB
|
308 lines
/* This program implements a little gadget link definition for use with
* HT and various editors. You can easily click your way through defining
* an entire link. The string this function returns is what needs to be
* inserted into the document.
*/
/****************
* D.B.G. 1990
****************/
/* should check for failure of these calls */
if ~Show('L', 'rexxsupport.library') then
check = AddLib('rexxsupport.library', 10, -30, 0)
if (check == 0) then do
say "Need to have the rexxsupport library in LIBS:!"
exit
end
if ~Show('L', 'rexxarplib.library') then
check = AddLib('rexxarplib.library', 10, -30, 0)
if (check == 0) then do
say "Need to have the rexxarplib.library and screenshare.library in LIBS:"
exit
end
/* this variable and its stems define the gadget names and the
* associated file name. Change them to suit your system.
*/
cport = 'LINK_PORT'
notport = 'LINK_notify'
address AREXX "'x=call CreateHost(" cport "," notport ")'"
do until ShowList(P,cport)
call Delay(10)
end
idcmp = 'CLOSEWINDOW+WINDOWDRAG+GADGETUP'
flags = 'WINDOWCLOSE+WINDOWDRAG+BACKFILL'
call OpenWindow(cport, 150, 20, 295, 160, idcmp, flags, 'Link Requestor')
call ActivateWindow(cport)
/* we want to add the string gadget first so you can start typing into it
* right away
*/
gadg.9.name = "" ;
call AddGadget(cport, 25, 105, "gadg9", gadg.9.name, "%g", 250)
call ActivateGadget(cport, gadg9)
/* print some text and lines to explain things */
call SetDrMd(cport, COMPLEMENT)
call Move(cport, 25, 20)
call Text(cport, "Link Type :")
call Move(cport, 25, 23)
call Draw(cport, 115, 23)
call Move(cport, 25, 94)
Call Text(cport, "Link Information :")
call Move(cport, 25, 97)
call Draw(cport, 170, 97)
call SetAPen(cport, 1)
call Move(cport, 10, 80)
call Draw(cport, 285, 80)
call Move(cport, 30, 51)
call Draw(cport, 245, 51)
gadg.1.name = "Anim " ; gadg.2.name = "Arexx" ; gadg.3.name = "Play " ;
gadg.4.name = "Link " ; gadg.5.name = "Show " ; gadg.6.name = "Rexx " ;
gadg.7.name = "Sound" ; gadg.8.name = " Run " ;
gadg.10.name = "File List" ; gadg.11.name = "Preview Link"
gadg.12.name = "CANCEL"
cur_linktype = 4
gadg.1.info = "[anim options] <Anim filename>"
gadg.2.info = "<ARexx program> [options]"
gadg.3.info = "[options] <SMUS filename>"
gadg.4.info = "<filename> [Text to link to]"
gadg.5.info = "[options] <Picture filename>"
gadg.6.info = gadg.2.info
gadg.7.info = "[options] <Sound filename>"
gadg.8.info = "<External program> [options]"
/* gadg.9 is the string gadget */
call write_info(gadg.cur_linktype.info)
gadg.1.x = 25 ; gadg.2.x = 85 ; gadg.3.x = 150 ; gadg.4.x = 210 ;
gadg.5.x = 25 ; gadg.6.x = 85 ; gadg.7.x = 150 ; gadg.8.x = 210 ;
gadg.1.y = 30 ; gadg.2.y = 30 ; gadg.3.y = 30 ; gadg.4.y = 30 ;
gadg.5.y = 58 ; gadg.6.y = 58 ; gadg.7.y = 58 ; gadg.8.y = 58 ;
do i = 1 to 8
call AddGadget(cport, gadg.i.x, gadg.i.y, "gadg", gadg.i.name, i)
end
call AddGadget(cport, 15, 140, "gad10", gadg.10.name, '10' )
call AddGadget(cport, 180, 140, "gad11", gadg.11.name, '11' )
call AddGadget(cport, 110, 140, "gad12", gadg.12.name, '12' )
call highlight_type gadg.cur_linktype.x gadg.cur_linktype.y
mainport = 'MP'
mport = OpenPort(mainport)
do until ShowList(P, mainport)
call delay(10)
end
call SetNotify(cport, GADGETUP, mainport)
call SetNotify(cport, CLOSEWINDOW, mainport)
notquit = 1
call SetDrMd(cport, COMPLEMENT)
/* get the ht.config file here. we wait so long to do this, so everything
* has already been opened and there aren't any unnecessary delays.
* this function creates a stemmed variable called htconfig.
*/
call get_htconfig()
do while notquit
call WaitPkt(mainport)
packet = GetPkt(mainport)
if packet ~== '0000 0000'x then
do
id = GetArg(packet, 0)
call Reply(packet, 0)
select
when id = 'CLOSEWINDOW' then call closeup()
when id > 0 & id < 9 then
do
call highlight_type gadg.cur_linktype.x gadg.cur_linktype.y
call highlight_type gadg.id.x gadg.id.y
call write_info gadg.id.info
cur_linktype = id
end
when id = 10 then
call do_filerequest()
when id = 11 then
call preview_link()
when id = 12 then do
call stop("LINK_PORT")
exit ""
end
otherwise
call closeup()
end
end
end
exit
closeup:
options results
id = get_gadg_string()
call stop("LINK_PORT")
if id = "" then
exit ""
l_name = strip(gadg.cur_linktype.name, B)
ret = "\"l_name" {" id "}"
exit ret
return
write_info:
parse arg string
call SetDrMd(cport, JAM1)
call RectFill(cport, 10, 120, 275, 130)
call Move(cport, 25, 127)
call SetDrMd(cport, COMPLEMENT)
call Text(cport, string)
return
highlight_type:
parse arg x y
y = y - 1
call AreaMove(cport, x+15, y+20)
call AreaDraw(cport, x+25, y+20)
call AreaDraw(cport, x+20, y+15)
call AreaDraw(cport, x+15, y+20)
call AreaEnd(cport)
drop x y
return
do_filerequest:
/* check if there is a default path to use. If not we get a null string
* back and that's o.k. too.
*/
pathname = GetClip("HT_LINK_PATH")
res = GetFile(15, 10, pathname, "", "Select name of file use:")
/* now we have to put any base path name back in the clip list for
* future use
*/
if ( res ~= "" & LastPos("/", res) > Pos(":", res) ) then
SetClip( "HT_LINK_PATH", Left(res, LastPos("/", res) - 1) )
else if (res ~= "") then
SetClip( "HT_LINK_PATH", Left(res, Pos(":", res)) )
cur_name = get_gadg_string()
/* if true, we have to extract relevant info and keep it */
if cur_name ~= "" then do
parse var cur_name . stuff
res = res || stuff
end
gadg.9.name = res
call RemoveGadget(cport, "gadg9")
call AddGadget(cport, 25, 105, "gadg9", gadg.9.name, "%g", 250)
call RefreshGadgets(cport)
call ActivateGadget(cport, "gadg9")
drop res cur_name
return
preview_link:
string = get_gadg_string()
if string = "" then do
Request(50, 50, "No link to preview", , "Gotcha", "O.k. bud")
return
end
/* string now has the actual link information that would be used by HT */
/* based on the current link type we will "do" that link */
id = upper(strip(gadg.cur_linktype.name, 'B')) /* strip all blanks */
if (id == "LINK") then do
call startht.rexx()
call Delay(10) /* make sure HT has started ! */
end
interpret htconfig.id "'"string"'" /* actually execute the link ! */
drop string fname id
return
/* returns the string contained in the string gadget. This routine
* should be generalized more
*/
get_gadg_string:
options results
call ReadGadget(cport, gadg9)
call WaitPkt(mainport)
packet = GetPkt(mainport)
ret = GetArg(packet, 0)
call Reply(packet, 0)
return ret
/* find and open the ht.config file. Parse its contents and create a
* stemmed variable htconfig which holds the commands strings to be
* used in preview_link. The stems of htconfig are going to be interpreted
* so we must prepend an "address command" to what we read in from the file.
*/
get_htconfig:
/* now we set up defaults... */
htconfig.SHOW = "address command show "
htconfig.ANIM = "address command showanim "
htconfig.SOUND = "address command ssp "
htconfig.PLAY = "address command play "
htconfig.REXX = "address REXX "
htconfig.AREXX = "address AREXX "
htconfig.RUN = "address command run "
htconfig.LINK = "address HT LOAD "
if ~open(conf, "s:ht.config", "READ") then /* check s: first */
if ~open(conf,"ht.config", "READ") then /* then check current dir */
return
/* now we've got a valid filehandle and should parse the file up */
do while ~eof(conf)
line = readln(conf)
if index(line, "#") == 1 then
iterate /* skip line because it's a comment */
word = upper(word(line, 1)) /* get the first word */
select
when word = "SHOW" then htconfig.show = "address command " || "'" || substr(line, length(word)+1) || "'"
when word = "SOUND" then htconfig.sound = "address command " || "'" || substr(line, length(word)+1) || "'"
when word = "PLAY" then htconfig.play = "address command " || "'" || substr(line, length(word)+1) || "'"
when word = "ANIM" then htconfig.anim = "address command " || "'" || substr(line, length(word)+1) || "'"
otherwise nop
end
end /* of while loop */
close(conf)
drop line word conf
return